--init.lua
--Main server lua file, initializes gamemode

AddCSLuaFile("cl_init.lua")				--Main client file
AddCSLuaFile("shared.lua")				--Shared data/functionality
AddCSLuaFile("config.lua")				--Client wants configuration info
AddCSLuaFile("ui/cl_plrinfohud.lua")	--Client UI functionality
AddCSLuaFile("jobs/jobsystem.lua")		--Client needs to use job system
AddCSLuaFile("jobs/jobs.lua")			--Client needs to know about what jobs there are

include("shared.lua")				--For shared code, like setting gamemode info
include("config.lua")				--For gamemode configuration values
include("wallet.lua")				--Load the money system
include("jobs/jobsystem.lua")		--Load the jobs system
include("jobs/jobs.lua")			--Create the jobs

--Notify players of EternityRP running
hook.Add("PlayerInitialSpawn", "notifyOfVersionOnSpawn", function(plr)
	local FindGameModes = file.FindDir("gamemodes/*", true)
	for _, folder in pairs(FindGameModes) do
		local info_txt = file.Read("gamemodes/"..folder.."/info.txt", true)
		if not info_txt then info_txt = "" end
		
		local Gamemode = util.KeyValuesToTable(info_txt)
		if Gamemode.name and string.lower(Gamemode.name) == "eternityrp" then 
			local version = Gamemode.version
			plr:PrintMessage(HUD_PRINTTALK, "This server is running EternityRP " .. Gamemode.version)
			break
		end
	end
end)
